package es.us.isa.jdbl.data;

import java.util.LinkedList;
import java.util.List;

import javax.persistence.EntityManager;

import es.us.isa.jdbl.domain.Member;
import es.us.isa.jdbl.domain.ToolDeveloped;
import es.us.isa.jdbl.domain.biblio.Contributors;
import es.us.isa.jdbl.domain.biblio.PaperInConference;

public class ToolDAO {

	public static List<ToolDeveloped> getAll(EntityManager em){
		return em.createQuery("from ToolDeveloped").getResultList();
		
	}
	
	public static List<ToolDeveloped> getByAuthor(EntityManager em, Member m){
		List<ToolDeveloped> lista = em.createQuery("from ToolDeveloped").getResultList();
		List<ToolDeveloped> resultado = new LinkedList<ToolDeveloped>();
		
		for (ToolDeveloped aux:lista){
			for (Member c:aux.getResearchStaff() ){
				if(c != null){
					
					if(c.equals(m)){
						resultado.add(aux);
					}
				}
			}
		}
		return resultado;
	}
}
